<template>
	<u-popup mode="center" :round="20" :show="portuniShow" @close="portuniClose" width="90%">
		<u-notify ref="uNotify" />

		<view style="min-height: 280rpx;padding-top:100rpx;width: 650rpx;" class="padding-sm">

			<uni-forms ref="valiForm" :rules="rulesFrom" :modelValue="mode" labelWidth="60px" label-position="left">
				<uni-forms-item label="密码" required name="content">
					<uni-easyinput  v-model="mode.content" placeholder="请输入密码"></uni-easyinput>
				</uni-forms-item>
			</uni-forms>
			<view style="position:absolute;bottom: 20rpx; left: 50%; transform: translateX(-50%); width: 100%;"
				class="flex justify-around">
				<view class="cu-btn round bg-gray" @click="portuniClose" style="width: 40%;">关闭</view>
				<view class="cu-btn round bg-green" style="width: 40%;" @click="portuniOpen">确定</view>
			</view>
		</view>
		<TipsModal :uModalShow="uModalShow" :uModalContent="uModalContent" @uModalCle="uModalCle"
			@uModalCom="uModalCom" />
	</u-popup>
</template>
<script>
	import TipsModal from '@/components/TipsModal/TipsModal.vue' //确定窗
	import myApi from '@/utils/app.js' //调用接口使用
	export default {
		name: 'CompletedMal',
		components: {
			TipsModal
		},
		data() {
			return {
				portuniShow: false,
				mode: {},
				rulesFrom: {
					content: {
						rules: [{
							required: true,
							errorMessage: '密码'
						}]
					},

				},
				uModalShow: false, //确定窗
				uModalContent: '你确定要备注吗？', //确定窗
			}
		},
		methods: {
			OnAdemin() {
				this.mode = {}
				this.portuniShow = true
			},
			portuniOpen() { // 确定触发
				this.$refs.valiForm.validate().then(res => {
					if (this.mode.content == '111'){
						this.$emit('ok')
						this.portuniClose()
					} 
					else this.onNotify({
						type: 'error',
						message: '密码错误'
					})
				}).catch(err => {
					this.onNotify({
						type: 'error',
						message: err[0].errorMessage,
					})
				})
			},
		
			// 确定框 确定
			async uModalCom() {
				this.$emit('OnOrderReply', this.mode)
				this.uModalCle()
			},
			// 取消删除
			uModalCle() {
				this.uModalShow = false
			},
			onNotify(round) {
				this.$refs.uNotify.show({
					type: round.type ? round.type : 'success',
					message: round.message ? round.message : '密码错误',
					top: 50
				})
			},
			portuniClose() {
				this.portuniShow = false
				this.mode = {}
			}
		}
	}
</script>